package com.wn.common.util;

import com.wn.common.pojo.Destination;
import com.wn.common.pojo.MaxAndMinLatAndLng;

public class FindPosition {

//    @Autowired
//    S

    public static MaxAndMinLatAndLng findNeighPosition(Destination destination){
        //先计算查询点的经纬度范围
        double r = 6371;//地球半径千米
        double dis = 400;//距离
        double dlng =  2*Math.asin(Math.sin(dis/(2*r))/Math.cos(destination.getLat()*Math.PI/180));
        dlng = dlng*180/Math.PI;//角度转为弧度
        double dlat = dis/r;
        dlat = dlat*180/Math.PI;

        double minlat =destination.getLat()-dlat;
        double maxlat = destination.getLat()+dlat;
        double minlng = destination.getLng()-dlng;
        double maxlng = destination.getLng()+ dlng;

        //将计算的最大最小存入对象
        MaxAndMinLatAndLng maxAndMinLatAndLng = new MaxAndMinLatAndLng(minlat, maxlat, minlng, maxlng);

        return maxAndMinLatAndLng;

    }

}
